<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="./css/aui.css" />    
    <link rel="stylesheet" type="text/css" href="./css/aui-slide.css" />
    <link rel="stylesheet" type="text/css" href="./css/font-awesome.css" />
    <link rel="stylesheet" type="text/css" href="./css/style.css" />
    <script type="text/javascript" src="./script/jquery.min.js"></script>
    <script type="text/javascript" src="./script/doT.min.js"></script>
    <script type="text/javascript" src="./script/base.js"></script>
    <script type="text/javascript" src="./script/api.js"></script></head>
    <script type="text/javascript" src="./script/jquery-3.2.0.js"></script>
</head>
<body>

    <header class="header header-f" style="padding-top:2rem; height:4.3rem;">
        <div class="header-l aui-pull-left" onclick="closeWin()">
            <i class="fa fa-angle-left"></i>
        </div>
        <div class="header-title">
            提现明细
        </div>
        <div class="header-r aui-pull-right">
        </div>
    </header>
    <div style="height:4.3rem;"></div>


    <ul class="distribution-withdraw-nav">
<!--         <li id="all" onclick="changeSort('all');">所有</li>
        <li id="waitCheck" onclick="changeSort('waitCheck');">待审核</li>
        <li id="waitPay" onclick="changeSort('waitPay');">待打款</li>
        <li id="hasPay" onclick="changeSort('hasPay');">已打款</li>
        <li id="noEffect" onclick="changeSort('noEffect');">无效</li> -->
        <li id="1" onclick="changeSort('1');">处理中</li>
        <li id="2" onclick="changeSort('2');">已完成</li>
        <li id="0" onclick="changeSort('0');">失败</li>

    </ul>
    <div id="list">
<!--     <div class="distribution-withdraw-item">
        <ul class="distribution-withdraw-item-t">
            <li>
                提现到微信
                <p>2018-12-06 14:13</p>
            </li>
            <li>
                +0.00
                <p>待审核</p>
            </li>
        </ul>
        <ul class="distribution-withdraw-item-d">
            <li>
                申请佣金
                <p>235.60</p>
            </li>
            <li>
                实际金额
                <p>235.60</p>
            </li>
            <li>
                提现手续费
                <p>0.00元</p>
            </li>
        </ul>
    </div>
    <div class="distribution-withdraw-item-btn" tapmode onclick="withdrawdetails()">查看提现详情</div> -->
</div>
</body>
<script type="text/javascript" src="./script/api.js"></script>
<script type="text/template" id="template">
    <div class="distribution-withdraw-t">
        账户余额：+{{=it.money}}元
    </div>
    {{~it.data:value:index}}
    <div class="distribution-withdraw-item">
        <ul class="distribution-withdraw-item-t">
            <li>
                提现到{{=value.bank}}
                {{? value.status == 2}}
                <p>{{=value.complete_time}}</p>
                {{??}}
                <p>{{=value.create_time}}</p>
                {{?}}
            </li>
            <li>
                +{{=value.money}}元
                <p>{{=value.show_status}}</p>
            </li>
        </ul>
        <ul class="distribution-withdraw-item-d">
<!--             <li>
                申请佣金
                <p>{{=value.account}}元</p>
            </li> -->
            <li>
                实际金额
                <p>{{=(value.money-value.money_tax)}}元</p>
            </li>
            <li>
                提现手续费
                <p>{{=value.money_tax}}元</p>
            </li>
        </ul>
    </div>
    {{? value.status == 0}}
    <div class="distribution-withdraw-item-btn" tapmode>{{=value.auth_remark}}</div>
    {{?}}
    {{~}}
</script>
<script type="text/javascript">

    apiready = function(){
        $('#1').addClass('active');
        type = 1;
        loadData();
    }
    
    function changeSort(sort){
        $('li').removeClass('active');
        $('#'+sort).addClass('active');

        if (sort == 0) {
            type = 3
        }else{
            type = sort;
        }
        loadData();
    }

    function loadData(){
        var userid = $api.getStorage('userid');
        var authtoken = $api.getStorage('authtoken');
        api.ajax({
            url: webAddress + '/a/member/cash',
            method: 'get',
            data: {
                values: {
                    limit: limit,
                    type: type,
                },
            },
            headers: {
                TOKEN: token,
                authuid: userid,
                authtoken: authtoken,
            },
        },function(ret, err){
            if (ret) {
                // alert( JSON.stringify( ret ) );
                var data = ret.result.data;
                for (var i = 0; i < data.length; i++) {
                    data[i].create_time = toDate(data[i].create_time);
                    data[i].complete_time = toDate(data[i].complete_time);
                }
                ret.result.data = data;
                templateFun(ret.result);
            } else {
                // alert( JSON.stringify( err ) );
                // api.toast({
                //     msg: err.body.message,
                //     duration: 2000,
                //     location: 'bottom'
                // });
                templateFun2();
                return false;
            }
        });
    }

    // 模板赋值函数
    function templateFun(data){
        var template = $api.byId('template');
        var dotFn = doT.template(template.innerHTML);
        var html = dotFn(data);
        var list = $api.byId('list');
        $api.html(list, html);
    }

    // 无数据
    function templateFun2(data){
        var list = $api.byId('list');
        var html = '<h2 style="padding:1rem; text-align:center; color:#999; font-size:1rem;">暂无更多记录</h2>';
        list.innerHTML = html;
    }

    // 字符串转时间
    function toDate(timestamp){
            // 宁哥提供代码
            // var newDate = new Date();
            // newDate.setTime(timestamp * 1000);
            // return newDate.toLocaleDateString();
            
            //时间戳为10位需*1000，时间戳为13位的话不需乘1000
            var date = new Date(timestamp * 1000);
            var Y = date.getFullYear() + '-';
            var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
            var D = date.getDate() + ' ';
            var h = date.getHours() + ':';
            var m = date.getMinutes() + ':';
            var s = date.getSeconds();
            return Y+M+D+h+m+s;
            // return Y+M+D;
        }

    //    
    function withdrawdetails(){
        var delay = 0;
        if(api.systemType != 'ios'){
            delay = 300;
        }
        api.openWin({
            name: 'withdrawdetails',
            url: './distribution_withdraw_details.html',
            bounces:false,
            delay: delay,
            slidBackEnabled:true,
            vScrollBarEnabled:false,
            progress:{
                type:"page"
            }
        });
    }

    function closeWin(){
        api.closeWin({
        });
    }
</script>
</html>